<template>
  <span class="text-action">￥{{ formatNum }}</span>
</template>

<script setup>
import { computed } from 'vue'
const props = defineProps({
  num: [Number, String]
})

const formatNum = computed(() => {
  const s = String(props.num || '0').split('.');
  const int = s[0];
  s[0] = '';
  for (let i = int.length - 1; i >= 0; i--) {
    if ((int.length - i - 1) % 3 === 0 && i !== int.length - 1) {
      s[0] = int[i] + ',' + s[0]
    } else {
      s[0] = int[i] + s[0]
    }
  }
  return s.join('.');
})
</script>